package com.is.add.controller.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * HTML静态页面
 */
@Controller
public class PageController {


    /**
     * 静态页面处理程序
     * 主页面
     * @return 返回HTML静态页面
     */
    @RequestMapping("/web/**")
    public String forwardIndex() {
        return "forward:/index.html";
    }

    @RequestMapping(value = "/web/settle/{userId}", produces = "application/json;charset=UTF-8")
    public String forwardIndex1(@PathVariable String userId, HttpServletRequest request) {
        System.out.println("----------userId"+userId);
        HttpSession session = request.getSession();
        //将数据存储到session中
        session.setAttribute("userId", userId);
        return "forward:/index.html";
    }

    /**
     * 静态页面处理程序
     * 默认显示login页面
     * @return 返回HTML静态页面
     */
    @RequestMapping("/")
    public String forward() {
        return "forward:/index.html";
    }

    /**
     * 静态页面处理程序
     * 登录页面
     * @return 返回HTML静态页面
     */
    @RequestMapping("/login/**")
    public String forwardLogin() {
        return "forward:/login.html";
    }

    /**
     * 静态页面处理程序
     * 测试页面
     * @return 返回HTML静态页面
     */
    @RequestMapping("/test/**")
    public String forwardTest() {
        return "forward:/test.html";
    }
}
